import { formDate,setSStore,Trim } from "@/utils/util"
import Load from '@/components/Load.vue'
export default {
	data() {
		return {
			loading:false,
			data:[],
			query:{
				orderNumber:'',
				buyerName:'',
				toStartDate:'',
				toEndDate:'',
				orderStatus:'-1',
				ticketNo:'',
				pnr:'',
				mobile:'',
				tos:'',
				toe:'',
				page:1,
				rows:5,
			},
			status:[
				{name:'全部',key:-1},
				{name:'待支付',key:0},
				{name:'待出票',key:2},
				{name:'出票完成',key:4},
				{name:'已取消',key:5},
			],
			active:-1,
			total:null,
		}
	},
	computed: {
		
	},
	watch:{
		
	},
	methods: {
		search(){
			this.active = -1;
			this.query.orderStatus = -1;
			this.getData();
		},
		getData(){
			
			this.query.toStartDate = formDate(this.query.toStartDate);
			this.query.toEndDate = formDate(this.query.toEndDate);
			this.query.tos = formDate(this.query.tos);
			this.query.toe = formDate(this.query.toe);
			this.query.orderNumber = Trim(this.query.orderNumber);
			this.query.mobile = Trim(this.query.mobile);
			this.query.buyerName = Trim(this.query.buyerName);
			this.query.ticketNo = Trim(this.query.ticketNo);
			this.query.pnr = Trim(this.query.pnr);
			
	        this.loading = true;
			this.$http.get('/order/getBuyerList',{params:this.query})
				.then((res) => {
					this.loading = false;
					let rows = res.data.rows;
					let total = res.data.total;
					if(rows){
						this.data = rows;
						this.total = total;
						if(this.data.length==0){
							this.$message('搜索结果为空');
							return;
						}
						return;
					}
					this.$notify.error({
			          title: '请求失败',
			          message: '请检查网络连接或者更换搜索条件',
			          duration: 3000
			        });
				})
		},
		//选择不同状态的订单数据
		chooseStatus(status){			
			this.query.orderStatus = status;
			this.getData();
			this.active = status;
		},
		//分页
		pageChange(val){
			this.query.page = val;
			this.getData();
		},
		//查看订单详情
		detail(order){
			window.open(`#/orderManage/flight/detail?orderNumber=${order.orderNumber}`)
		},
		//修改订单
		editOrder(){
			alert("功能待明确")
		},
		//导出订单
		exportOrder(){
			alert("功能待明确")
		}
	},
	components:{
		Load,
	},
	created() {
		this.getData();
	}
}